package com.googlecode.bip.entity;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Referent object : user Referent (read write)
 *
 * @author Claude CHOISNET
 */
public class ReferentReferentView
    extends Referent
        implements IReferentReferentView, Serializable
{
    private static final long serialVersionUID = 1L;
    private String username;
    private String password;

    /**
     *
     */
    public ReferentReferentView()
    {
    }

    /**
     * Create a shadow copy of giving ReferentReferentView
     *
     * @param o UserReferent to clone
     */
    public ReferentReferentView( final ReferentReferentView o )
    {
        super( o );

        this.username  	= o.username;
        this.password   = o.password;
    }

    /**
     * Initialize a ReferentReferentView from ResultSet
     *
     * @param rSet
     * @return
     * @throws SQLException
     */
    public IReferentReferentView set( final ResultSet rSet ) throws SQLException
    {
        super.set( rSet );

        username	= rSet.getString( "username" );
        password 	= rSet.getString( "password" );

        return this;
    }

    /* (non-Javadoc)
     * @see com.googlecode.bip.entity.IReferent#setIdReferent(int)
     */
    @Override
    public void setIdReferent( int idreferent )
    {
        super.setIdReferent( idreferent );
    }

    /* (non-Javadoc)
     * @see com.googlecode.bip.entity.IReferent#setReferentName(java.lang.String)
     */
    @Override
    public void setReferentName( String referentname )
    {
        super.setReferentName( referentname );
    }

    /* (non-Javadoc)
     * @see com.googlecode.bip.entity.IReferent#setReferentDescription(java.lang.String)
     */
    @Override
    public void setReferentDescription( String referentdescription )
    {
        super.setReferentDescription( referentdescription );
    }

    @Override
    public void setLoginUserName( String username )
    {
        this.username = username;
    }

    @Override
    public String getLoginUserName()
    {
        return this.username;
    }

    @Override
    public void setPassWord( String password )
    {
        this.password = password;
    }

    public String private_getLoginPassWord()
    {
        return this.password;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result
                + ((password == null) ? 0 : password.hashCode());
        result = prime * result
                + ((username == null) ? 0 : username.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (!super.equals(obj))
            return false;
        if (getClass() != obj.getClass())
            return false;
        ReferentReferentView other = (ReferentReferentView) obj;
        if (password == null) {
            if (other.password != null)
                return false;
        } else if (!password.equals(other.password))
            return false;
        if (username == null) {
            if (other.username != null)
                return false;
        } else if (!username.equals(other.username))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "ReferentReferentView [username=" + username + ", password="
                + password + ", getIdReferent()=" + getIdReferent()
                + ", getReferentName()=" + getReferentName()
                + ", getReferentDescription()=" + getReferentDescription()
                + "]";
    }

}
